#!/bin/bash
update=$1
if [ "$1" = "update" ]; then
  sudo apt-get update
  sudo apt-get upgrade
  sudo apt-get install make build-essential libssl-dev zlib1g-dev
  sudo apt-get install libbz2-dev libreadline-dev libsqlite3-dev wget curl
  sudo apt-get install llvm libncurses5-dev libncursesw5-dev
  sudo apt-get install liblzma-dev
  sudo apt-get install lzma
  echo "muyi@123" | sudo -S sudo rm -rf /home/catmd5
  cd ~/catmd5 && tar -xzvf pyenv.tar.gz && mv pyenv ~ && mv ~/pyenv ~/.pyenv && rm -rf ~/catmd5/pyenv*
  echo 'export PYENV_ROOT="$HOME/.pyenv"' >>~/.bashrc
  echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >>~/.bashrc
  echo 'eval "$(pyenv init -)"' >>~/.bashrc
  echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc
#  echo 'eval "$(pyenv virtualenv-init -)"' >>~/.bashrc
fi
if [ "$1" = "install" ]; then
#  source ~/.bashrc
  export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1
  export PYTHON_BUILD_MIRROR_URL="https://mirrors.huaweicloud.com/python/"
  cd ~/catmd5 && pyenv install 3.8.15 && pyenv local 3.8.15 && pip install --upgrade pip && pip install pipenv
  sudo ln -s /home/muyi/.pyenv/shims/pipenv pipenv && mkdir .venv && pipenv --python 3.8
  echo "muyi@123" | sudo -S sudo mv ~/catmd5 /home && sudo chown -R muyi:muyi /home/catmd5 && chmod +222 /home/catmd5
  cd /home/catmd5 && pipenv install paramiko pandas
#  pipenv install --dev nuitka
#  .venv/bin/python3 -m nuitka  --windows-disable-console --nofollow-imports --show-memory --show-progress --output-dir=out_1 map_md5.py
#  .venv/bin/python3 -m nuitka  --windows-disable-console --nofollow-imports --show-memory --show-progress --output-dir=out_1 check_cross.py
#  .venv/bin/python3 -m nuitka  --windows-disable-console --nofollow-imports --show-memory --show-progress --output-dir=out_1 ros_md5.py
#  .venv/bin/python3 -m nuitka --module --show-progress --output-dir=m cmd_line.py


fi
